package com.diligent.cloud.sfc.resources;

import com.canny.commons.model.ListResult;
import com.canny.commons.model.ObjectResult;
import com.canny.commons.model.Result;
import com.diligent.cloud.sfc.model.params.OrderListParams;
import com.diligent.cloud.web.model.PageAndCondition;
import com.diligent.cloud.web.resource.AdaptationBaseResource;
import com.diligent.cloud.workorder.model.WoOrder;
import com.diligent.cloud.workorder.model.WoOrderProgressParams;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.security.core.annotation.AuthenticationPrincipal;
import org.springframework.web.bind.annotation.*;

import java.security.Principal;

/**
 * WoOrderResource class
 * 工单资源
 *
 * @author xf107278
 * @date 3/27/2020
 */
@RequestMapping("/sfc/wo-order")
public interface WoOrderResource extends AdaptationBaseResource<WoOrder> {

    /**
     * 根据工单所在工位获取相对应的工控屏信息
     *
     * @param orderId
     * @return
     */
    @GetMapping("/{orderId}/{stationType}")
    @ApiOperation(value = "工单/根据工单所在工位获取相对应的工控屏信息", notes = "工单/根据工单所在工位获取相对应的工控屏信息", tags = "工单/工序")
    ResponseEntity<Result> getOrderAcInfo(@ApiParam(name = "orderId", value = "工单id", type = "Long") @PathVariable Long orderId,
                                          @ApiParam(name = "stationType", value = "工位类型", type = "Integer") @PathVariable Integer stationType, @AuthenticationPrincipal Principal principal);

    @PostMapping
    @ApiOperation(value = "工单/新增工单", notes = "工单/新增工单"  , tags = "工单/工序")
    ResponseEntity<Result> addOrder(@RequestBody WoOrder woOrder, @AuthenticationPrincipal Principal principal);

    @PostMapping(value = "/filter")
    @ApiOperation(value = "工单/查询工单列表", notes = "工单/查询工单列表", tags = "工单/工序")
    ResponseEntity<ListResult> getOrderList(@RequestBody OrderListParams orderListParams, @AuthenticationPrincipal Principal principal);

    @GetMapping(value = "/{prodBatch}/{machCode}/{orderType}/{systemId}/{isFinished}/{operationIsFinished}")
    @ApiOperation(value = "工单/根据批次查询工单列表", notes = "工单/根据批次查询工单列表", tags = "工单/工序")
    ResponseEntity<ListResult> getSameOrderByProdBatch(@PathVariable("prodBatch") String prodBatch, @PathVariable("machCode") String machCode, @PathVariable("orderType") Integer orderType, @PathVariable("systemId") Long systemId, @PathVariable("isFinished") Integer isFinished,@PathVariable("operationIsFinished") Integer operationIsFinished);

//    @PostMapping("/lot/{boxCode}/{systemId}")
//    @ApiOperation(value = "工单/生成随行卡", notes = "工单/生成随行卡", tags = "工单/工序")
//    ResponseEntity<ObjectResult> addWoOrderLots(@PathVariable("boxCode") String boxCode, @PathVariable("systemId") Long systemId, @AuthenticationPrincipal Principal principal);

    @PostMapping(value = "/progress/filter", produces = {MediaType.APPLICATION_JSON_VALUE})
    @ApiOperation(value = "工单/获取工单进度", notes = "工单/获取工单进度", tags = "工单/工序")
    ResponseEntity<com.diligent.cloud.primary.data.model.Result> getWoOrderProgress(@RequestBody WoOrderProgressParams orderProgressParams);

    @PutMapping("/actions/{action}")
    @ApiOperation(value = "工单/设置工单状态", notes = "工单/设置工单状态", tags = "工单/工序")
    ResponseEntity<com.diligent.cloud.primary.data.model.Result> updateDocStatus(@PathVariable("action") String action, @RequestBody WoOrder woOrder, @AuthenticationPrincipal Principal principal);

    @PostMapping(value = "/search", produces = {MediaType.APPLICATION_JSON_VALUE})
    @ApiOperation(value = "工单/根据条件查询工单", notes = "工单/根据条件查询工单", tags = "工单/工序")
    ResponseEntity<ObjectResult> getOrderByPageAndCondition(@RequestBody  PageAndCondition pageAndCondition);


}
